package definite.Guide.Book.LayoutManager;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;

public class BoxSample {

	public static void main(String[] args) {
		Runnable r = new Runnable() {

			@Override
			public void run() {
				JFrame.setDefaultLookAndFeelDecorated(true);
				JFrame verFrame = new JFrame("Vertical Box Demo");
				verFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
				// create Box
				Box verBox = Box.createVerticalBox();
				// Component glue = Box.createHorizontalGlue();
				// verBox.add(glue);
				JButton top = new JButton("TOP");
				JButton center = new JButton("CENTER");
				JButton but = new JButton("BUTTOM");
				verBox.add(center);
				verBox.add(but);

				// create another Box
				Box horBox = Box.createHorizontalBox();
				JLabel left = new JLabel("LEFT");
				JLabel middle = new JLabel("MIDDLE");
				JLabel right = new JLabel("RIGHT");
				horBox.add(left);

				horBox.add(middle);
				horBox.add(right);
				verFrame.add(horBox, BorderLayout.SOUTH);
				verFrame.add(verBox, BorderLayout.CENTER);
				verFrame.pack();
				verFrame.setLocationRelativeTo(null);
				verFrame.setSize(150, 150);
				verFrame.setVisible(true);
			}
		};

		EventQueue.invokeLater(r);
	}
	/*Instead of directly using the Box.Fillerclass, several static methods of the Boxclass can 
	help you create the appropriate filler components. The factory methods allow you to categorize 
	these components by type, instead of by minimum, maximum, or preferred size. You’ll look at 
	these methods in the next two sections.
	If you’re interested in the class definition, it’s shown next. Like the Boxclass, Box.Filler
	isn’t meant to be used as a JavaBean component.
	
	public class Box.Filler extends Component implements Accessible {
	// Constructors
	public Filler(Dimension minSize, Dimension prefSize, Dimension maxSize);
	// Properties
	public AccessibleContext getAccessibleContext();
	public Dimension getMaximumSize();
	public Dimension getMinimumSize();
	public Dimension getPreferredSize();
	// Others
	protected AccessibleContext accessibleContext;
	public void changeShape(Dimension minSize, Dimension prefSize, Dimension maxSize);
	}*/
}
